package org.apache.tomcat.util;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Collections;
import java.util.Map;
import java.util.Set;

public class PrintUtils {

    private static final Logger log = LoggerFactory.getLogger(PrintUtils.class);

    public static <K, V> void logPretty(Map<K, V> map) {
        if (map == null || map.isEmpty()) {
            return;
        }
        final Set<Map.Entry<K, V>> entries = map.entrySet();
        for (Map.Entry<K, V> entry : entries) {
            final K key = entry.getKey();
            final V value = entry.getValue();
            log.info("Map key-->" + key + ",value-->" + value);
        }
    }

    public static <E> void logPretty(E[] array) {
        if (array == null || array.length == 0) {
            return;
        }
        for (int i = 0; i < array.length; i++) {
            final E e = array[i];
            log.info("|{} The index [{}] element in array is [{}]", Collections.nCopies(i,"_"), i, e);
        }
    }
}
